package com.yixun.qfbao.hander;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;

import com.yixun.qfbao.api.service.AreaService;
import com.yixun.qfbao.apidto.GetAreaForOtherReqDto;
import com.yixun.qfbao.apidto.GetAreaForOtherResDto;
import com.yixun.qfbao.constants.OpenApiConstant;
import com.yixun.qfbao.vo.GetAreaForOtherReqVo;
import com.yixun.qfbao.xf.model.enums.ResultEnum;

@Service("GetAreaForOtherHander")
public class GetAreaForOtherHander {
	private static final Logger logger = LoggerFactory.getLogger(GetAreaForOtherHander.class);
	@Autowired
	private AreaService areaService;

	public GetAreaForOtherResDto hander(GetAreaForOtherReqVo req) {
		GetAreaForOtherResDto resDTO = new GetAreaForOtherResDto();
		GetAreaForOtherReqDto getAreaForOtherReqDto = req.getParams();
		try {
			Assert.notNull(getAreaForOtherReqDto.getParentId(), "入参不能为空");
			resDTO = areaService.getArea(getAreaForOtherReqDto);
			resDTO.setResponseCode(ResultEnum.SUCCESS.getNo());
		} catch (Exception e) {
			resDTO.setResponseCode(OpenApiConstant.RC_EXCEPTION_ERROR.getResponseCode());
			resDTO.setResponseMessage(e.getMessage());
			logger.error("GetAreaForOtherHander err: {}", e);
		}

		return resDTO;
	}
}
